<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div>
    <el-row>
      <el-col :span='22' :xs='24'>
        <el-form ref="form" :model="s_use" :rules="rules" label-width="100px" id="mvcfm">
          <el-button @click="popUploadStandard('')" type='success' size="mini"><i class='fa fa-plus'></i>增加标准文件</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 标准列表 </span>
          </div>
          <el-table :data="s_use">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="d_use('&CMIDuse_id='+scope.row.use_id+'')">删除</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="popApplicableStandard('&fileverid='+scope.row.version_id+'')">查看</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="gotoPage('/xcapi/ProcessFile/DownloadFile.do?&fileverid='+scope.row.version_id+''+vueparams+'')">下载</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="#" align="center" type='index'>
            </el-table-column>
            <el-table-column label="使用标准" prop="version_id">
              <template slot-scope="scope">
              </template>
            </el-table-column>
          </el-table>
        </el-form>
      </el-col>
      <el-col :span='2' :xs='24'>
        <el-menu default-active='active' class='menu-unit'>
          <el-menu-item v-for='item in Container'>
            <el-link @click="gotoMenu(item.url)" :type="'使用标准'===item.name?'primary':'default'">{{item.page_desc||item.name}}</el-link>
          </el-menu-item>
        </el-menu>
      </el-col>
    </el-row>
    <el-dialog :visible.sync="UploadStandardVisible" append-to-body>
      <UploadStandard v-if="UploadStandardVisible" ref="UploadStandard" :popparams="popparams"> </UploadStandard>
    </el-dialog>
    <el-dialog :visible.sync="ApplicableStandardVisible" append-to-body>
      <ApplicableStandard v-if="ApplicableStandardVisible" ref="ApplicableStandard" :popparams="popparams"> </ApplicableStandard>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import UploadStandard from "@/views/mes/certificate/UploadStandard";
  import ApplicableStandard from "@/views/mes/certificate/ApplicableStandard";
  export default {
    name: 'ApplicableStandard',
    components: {
      UploadStandard,
      ApplicableStandard,
    },
    props: ['popparams'],
    data() {
      return {
        UploadStandardVisible: false,
        UploadStandardValue: null,
        UploadStandardDesc: null,
        ApplicableStandardVisible: false,
        ApplicableStandardValue: null,
        ApplicableStandardDesc: null,
        vueparams: this.getVUEParams(""),
        s_use: [],
        loading: false,
        Container: null,
        rules: {}
      }
    },
    created() {
      this.getData();
      this.loadContainerMenu({
        pid: "018E412E935E4B3EB6DF631BB3B46A50",
        name: "客户右菜单类型",
        selected: "使用标准"
      }, 'Container', this.vueparams);
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/mes/certificate/CertificateAction/applicableStandard?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      d_use(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/mes/certificate/CertificateAction/d_use?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      popUploadStandard(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.UploadStandardVisible = !this.UploadStandardVisible;
      },
      popApplicableStandard(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.ApplicableStandardVisible = !this.ApplicableStandardVisible;
      },
    },
  }
</script>
